<template>
	<scroll-view class="backview" bounces="false">
		<lexiconNavVue title="词源词库" />
		<view class="top-menu">
		</view>
		<scroll-view class="words-scroll" :style="{ height: scrollHeight + 'px'}" scroll-y
			:scroll-with-animation='true'>
			<view class="lexIcon-content">
				<view class="lexIcon-back">
					<view class="gameType-topTitle-view">
						<view class="gameType-topTitle">
							词源分类 | Etymology classification
						</view>
						<view class="gameType-line"></view>
					</view>
					<block v-for="(item, index) in wordCategoryList" ;key="index">
						<view class='word-category-item' @click="toWordLibraryDescription" :data-index="index">
							{{item.name}}
						</view>
					</block>
				</view>
			</view>
		</scroll-view>
	</scroll-view>
</template>

<script>
	export default {
		data() {
			return {
				wordCategoryList: [],
				scrollHeight: uni.getSystemInfoSync().windowHeight,
			}
		},
		onReady() {
			const that = this
			uni.createSelectorQuery().select('.top-menu').boundingClientRect(rect => {
				that.scrollHeight = uni.getSystemInfoSync().windowHeight - rect.bottom - 20;
			}).exec();
		},
		onLoad() {
			this.getWordCategoryList();
		},
		methods: {
			getWordCategoryList() {
				this.$http.languageOriginList({}).then(res => {
					if (res.code === 200) {
						this.wordCategoryList = res.data;
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			toWordLibraryDescription(e) {
				var selectData = this.wordCategoryList[e.currentTarget.dataset.index];
				uni.navigateTo({
					url: '/pages/lexicon/lexWordList?wordModel=' + JSON.stringify(selectData) + '&wordType=' +
						'product',
				})
			}
		}
	}
</script>

<style lang="less">
	.backview {
		width: 100%;
		height: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		top: 0;
		right: 0;
		background: #fff7dd;
	}

	.top-menu {
		width: 90%;
		margin-left: 5%;
		height: 5px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-around;
	}

	.lexIcon-content {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.lexIcon-back {
		width: 92%;
		display: flex;
		position: relative;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		border-radius: 20px;
		background-color: white;
		padding: 15px 0px;
		margin-top: 20px;
		margin-bottom: 20px;
		box-shadow: 2px 2px 10px 2px rgb(160, 160, 160);
	}

	.gameType-topTitle-view {
		width: 100%;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
	}

	.gameType-topTitle {
		font-family: 'hzgb';
		font-size: 15px;
		margin: 10px auto 5px 25px;
	}

	.gameType-line {
		width: 150px;
		height: 4px;
		background-color: var(--themeColor);
		margin-left: 25px;
	}

	.word-category-item {
		margin-top: 10px;
		margin-bottom: 10px;
		width: 80%;
		background: #000;
		color: #ffd52e;
		font-size: 18px;
		font-weight: 900;
		text-align: center;
		height: 40px;
		line-height: 40px;
		border-radius: 10px;
	}
</style>